Previous | Index | Next |

Input iterators

An input iterator must implement the methods defined in the interface InputIterator api. These methods are summarised in the table below. Assume that r and s are input iterators.

Input Iterator Requirements
expression return type note
r.cmp(s) boolean compare two iterators
r.next() Iterator advance the iterator
r.get() Object deference the iterator

For input iterators r.cmp(s) does not imply that r.next().cmp(s.next()). (Equality does not guarantee the substitution property or referential transparency). Algorithms on input iterators should never attempt to pass through the same iterator twice. They should be single pass algorithms. These algorithms can be used with InputStream as the source of the input data through the InputStreamIterator class.


Previous | Index | Next |